/*
package com.itheima.aop;


import com.itheima.Mapper.EmpLogMapper;
import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpLoginLog;
import com.itheima.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Aspect
@Slf4j
@Component
public class Hhhhh {

    @Autowired
    private EmpLogMapper empLogMapper;

    @Around("execution(* com.itheima.controller.LoginController.login(..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable{


        long start = System.currentTimeMillis();
        Result result = (Result) pjp.proceed();
        long end = System.currentTimeMillis();

        EmpLoginLog empLoginLog = new EmpLoginLog();

        //1接收参数用户名密码
        Emp emp = (Emp) pjp.getArgs()[0];
        empLoginLog.setUsername(emp.getUsername());

        empLoginLog.setPassword(emp.getPassword());
        //2.操作时间
        empLoginLog.setLoginTime(LocalDateTime.now());
        //3.返回值，是否成功
        empLoginLog.setIsSuccess(result.getCode().shortValue());

        if(result.getData()!=null){
            empLoginLog.setJwt(result.getData().toString().split("=")[4].split("\\)")[0]);
        }
        else{
            empLoginLog.setJwt(null);
        }

        //登录操作耗时
        empLoginLog.setCostTime(end-start);
        empLogMapper.loginLog(empLoginLog);
        return result;

    }


}
*/
